package com.bridgeQQ.client.control.commands
{
	import com.bridgeQQ.client.core.ICommand;
	import com.bridgeQQ.client.model.BridgeModel;
	import com.bridgeQQ.client.vo.FriendType;
	
	import mx.collections.ArrayCollection;

	public class RemoveFriendCommand extends BaseWrapper implements ICommand
	{
		public function RemoveFriendCommand(respond:BaseRespond)
		{
			super(respond);
		}
		
		protected override function result(info:Object):void
		{
			var result:Object = info.respond.value;
			if(result == null || !result.result)
			{
				fault(info);
				return;
			}
			var types:ArrayCollection = BridgeModel.instance.possess.friendTypes;
			//change name
			var typeID:Number = info.typeID;
			for(var i:int = types.length - 1; i >= 0; i--)
			{
				var type:FriendType = types.getItemAt(i) as FriendType;
				if(type == null || type.id != typeID)
				{
					continue;
				}
				type.friends.removeItemAt(type.friends.getItemIndex(info.item));
			}
			types.refresh();
		}
		
		protected override function fault(info:Object):void
		{
			
		}
		
	}
}